package com.douqu.game.core.config.map;

import com.douqu.game.core.config.common.GoodsData;
import com.douqu.game.core.entity.GameObject;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.util.LoadUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: Gavin.
 * Description:
 * Date: 2018/7/4 0004 上午 11:32
 * Huan Yu Copyright (c) 2017 All Rights Reserved.
 */
public class CityDropConfig extends GameObject {

    public String eventIcon, eventIconFrame, eventTag;
    /** 组id */
    public int groupId;

    /** 势力权重 */
    public int campWeight;

    /** 奖励掉落权重 */
    public int probabilityWeight;

    /** 类型  1 获取道具 2 直接使用道具*/
    public int useType;

    public int cityArmy;

    /** 奖励 */
    public GoodsData[] rewardId;

    public boolean check() {
        return super.check();
    }

    public boolean setVariable(String key, String value) {
        if ("rewardId".equals(key)){
            rewardId = LoadUtils.loadGoodDataToArray(key, value);
            return LoadUtils.checkGoods(rewardId, this.getClass(), key, id);
        }
        return super.setVariable(key, value);
    }

    public static List<CityDropConfig> getCityDropListByGroup(int group){
        List<CityDropConfig> cityDropConfigList = new ArrayList<>();
        List<CityDropConfig> list = DataFactory.getInstance().getDataList(DataFactory.CITY_DROP);
        for (CityDropConfig config:list){
            if (config.groupId == group){
                cityDropConfigList.add(config);
            }
        }
        return cityDropConfigList;
    }
}
